import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86155
 * date: 2024-01-23
 * Time: 11:08
 *
 * @author 逻辑控制作业
 */

public class test {
    //辗转相见法求最大公约数
    public static int jian(int a,int b){
        if(a<b){
            int c = a;
            a = b;
            b = c;
        }
        if(a == b){
            return a;
        }else {
            return jian((a-b),b);
        }
    }
    //辗转相处法最大公约数方法
    public static int zuixiao(int a,int b){
        if(a%b == 0){
            return b;
        }else {
            return zuixiao(b,a%b);
        }
    }

    //求最小公倍数
    public static void main(String[] args) {
        int a = 18;
        int b = 24;
        System.out.println("最小公倍数"+a*b/jian(a,b));
    }
    //求最小公约数辗转相除法
    public static void main14(String[] args) {
        int a = 12;
        int b = 24;
        int c = a%b;
        while(c != 0){
            a = b;
            b = c;
            c = a%b;
        }
        System.out.println(b);
    }
    //判断100以内的素数效率最快
    public static void main13(String[] args) {
        for (int i = 1; i <= 100 ; i++) {
            int j = 0;
            for (j = 2; j <= Math.sqrt(i); j++) {
                if (i%j == 0){
                    break;
                }
            }
            if(Math.sqrt(i) <= j){
                System.out.println(i);
            }

        }
    }
    //判断素数
    public static void main12(String[] args) {
        int n = 7;int i = 2;
        for (; i < Math.sqrt(n); i++) {
            if (n%i == 0){
                System.out.println("不是素数");
                break;
            }
        }
        if(Math.sqrt(n) <= i){
            System.out.println("是素数");
        }
    }
    //判断二级制奇数位和偶数位是1或者是零
    public static void main11(String[] args) {
        int a = 13;
        for (int i = 31; i >= 0 ; i-=2) {
            if(((a>>i)& 1) == 0){
                System.out.print(" "+0);
            }else {
                System.out.print(" "+1);
            }
        }
        System.out.println();
        for (int i = 30; i >= 0 ; i-=2) {
            if(((a>>i)& 1) == 0){
                System.out.print(" "+0);
            }else {
                System.out.print(" "+1);
            }
        }
    }
    //模拟输入三次密码
    public static void main10(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = 3;
        while(count != 0){
            System.out.println("请输入密码，还有"+count+"次机会");
            String pass = scanner.nextLine();
            if(pass.equals("123")){
                System.out.println("登录成功！");
                break;
            }else {
                System.out.println("登录失败!");
            }
            count--;
        }
    }
    //输出整数的每一位
    public static void main9(String[] args) {
        int a = 135;
        while(a!=0){
            System.out.println(a%10);
            a /= 10;
        }
    }
    //输出乘法口诀表
    public static void main8(String[] args) {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(i+"*"+j+"="+i*j+"  ");
            }
            System.out.println();
        }
    }
    //利用循环输出x
    public static void main7(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()){
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if ((i == j) || (i + j) == (n-1)) {
                        System.out.print('*');
                    } else {
                        System.out.print(' ');
                    }

                }
                System.out.println();
            }
        }
    }
    //水仙花数五位数
    public static void main6(String[] args) {
        //生成数字
        for (int i = 1; i < 100000; i++) {
            //判断位数
            int tmp = i;
            int count = 0;
            while(tmp != 0){
                tmp /= 10;
                count++;
            }
            //抽取每一位并求和
            tmp = i;
            int sum = 0;
            int ret = 0;
            while(tmp != 0){
                ret = tmp%10;
                sum += Math.pow(ret,count);
                tmp /= 10;
            }
            //判断
            if(sum == i){
                System.out.println(i);
            }
        }

    }
    //1-1/2+1/3.....+1/99-1/100
    public static void main5(String[] args) {
        double sum = 0.0;
        int flg = 1;
        for (int i = 1; i <= 100; i++) {
            sum += (1.0/i)*flg;//flg整形提升
            flg = -flg;
        }
        System.out.println(sum);
    }
    //判断二进制1的个数；
    public static void main4(String[] args) {
        int a = -1;
        int count = 0;
        for (int i = 0; i < 32; i++) {
            if(((a>>i)&1) != 0){
               count++;
            }
        }
        System.out.println(count);
    }
    public static void main3(String[] args) {
        int a = -1;
        int conut = 0;
        while(a != 0){
            a = a&(a-1);
            conut++;
        }
        System.out.println(conut);
    }
    public static void main2(String[] args) {
        int a = -1;
        int count = 0;
        while(a != 0){
            if((a & 1) == 1){
                count++;
            }
            a = a>>>1;
        }
        System.out.println(count);
    }
    public static void main1(String[] args) {
       /* //根据年龄, 来打印出当前年龄的人是少年(低于18), 青年(19-28), 中年(29-55), 老年(56以上)
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入年龄:");
        int age = scanner.nextInt();
        if(age <= 18){
            System.out.println("少年");
        }else if(age <= 28 && age >= 19){
            System.out.println("青年");
        }else if(age <= 55 && age >= 29){
            System.out.println("中年");
        }else if(age >= 56){
            System.out.println("老年");
        }
        //判定一个数字是否是素数
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入:");
        int a = scanner.nextInt();
        int i = 0;
        for (i = 2; i < a; i++) {

        }
        if(i == a){
            System.out.println("yes");
        }*/
        //打印 1 - 100 之间所有的素数

        for (int i = 1; i <= 1000 ; i++) {
            int j = 0;
            for ( j = 2; j < i; j++) {
                if(i%j == 0){
                    break;
                }
            }
            if(j >= i){
                System.out.println(i);
            }
        }
    }
}
